package pers.jassor.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import pers.jassor.entities.Dept;
import pers.jassor.service.DeptClientService;

@RestController
public class DeptControllerConsumer {
	
	// Feign的作用就是像使用接口一样编程
	@Autowired
	private DeptClientService service;
	
	@PostMapping("/consumer/dept")
	public boolean add(Dept dept) {
		return service.add(dept);
	}
	
	@GetMapping("/consumer/dept/{id}")
	public Dept get(@PathVariable("id") Long id) {
		return service.get(id);
	}

	@GetMapping("/consumer/dept")
	public List<Dept> get() {
		return service.list();
	}
	
//	@GetMapping("/consumer/dept/discovery")
//	public Object dicovery() {
//		return restTemplate.getForObject(REST_URL_PREFIX+"/dept/discovery", Object.class);
//	}
	
}
